package cn.tedu.egaddress1013.controller;


import cn.tedu.egaddress1013.mapper.AddressMapper;
import cn.tedu.egaddress1013.pojo.dto.AddressAddParam;
import cn.tedu.egaddress1013.pojo.entity.Address;
import cn.tedu.egaddress1013.pojo.vo.AddressInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController()
@RequestMapping("v1/address/")
public class AddressController {

    @Autowired
    private AddressMapper addressMapper;
    @PostMapping("add")
    public String addressAdd(@RequestBody AddressAddParam addressAddParam){
        addressMapper.addressAddById(addressAddParam);
        return "添加成功";
    }
    @GetMapping("list")
    public List<AddressInfoVO> addressList(){
        List<AddressInfoVO> list= addressMapper.addressListById();
        return list;
    }
    @PostMapping("del/{addressId}")
    public String addressDelete(@PathVariable Integer addressId){
        System.out.println(addressId);
        int rows=addressMapper.addressDelById(addressId);
        if(rows>0){
            return "删除成功";
        }else{
            return("不能删");
        }
    }


}
